package com.paomi.client.fragment.mine.presenter;


import com.paomi.client.activity.person.model.MyOrderNumBean;
import com.paomi.client.activity.person.model.TaskListBean;
import com.paomi.client.base.BaseLoadMorePresenter;
import com.paomi.client.base.BaseMvpLCEView;
import com.paomi.client.bean.BaseJSON;
import com.paomi.client.bean.UserInfoEntity;
import com.paomi.client.net.Api;
import com.paomi.client.net.BaseCallback;
import com.paomi.client.net.Constants;
import com.paomi.client.view.LoadingDialog;

import org.greenrobot.eventbus.EventBus;


import retrofit2.Call;

/**
 * Created by pc on 2018/10/25
 * Describe:
 * com.paomi.client.fragment.first.presenter
 */
public class MineFraPre extends BaseLoadMorePresenter<BaseMvpLCEView> {
    @Override
    protected void loadData(int page, int skip, boolean pullToRefresh) {
        LoadingDialog.get().hideLoading();
    }

    /**
     * 积分-完成任务
     */
    public void toSign(){
        Api.getInstanceService(Constants.User_URL).taskComplete("1").enqueue(new BaseCallback<BaseJSON>() {
            @Override
            public void onResponse(Call<BaseJSON> call, BaseJSON result) {
                EventBus.getDefault().post("SignSuccess");
            }
        });
    }



    /**
     * 用户-演出订单-数量统计
     */
    public void getOrderNum(){
        Api.getInstanceService(Constants.Ticket_URL).myOrderTotal("0,1,2,3,4,5,6,7").enqueue(new BaseCallback<MyOrderNumBean>() {
            @Override
            public void onResponse(Call<MyOrderNumBean> call, MyOrderNumBean result) {
                EventBus.getDefault().post(result);
            }
        });
    }

    /**
     * 获取积分任务列表
     */
    public void getTaskList(){
        Api.getInstanceService(Constants.User_URL).getTaskList().enqueue(new BaseCallback<TaskListBean>() {
            @Override
            public void onResponse(Call<TaskListBean> call, TaskListBean result) {
                EventBus.getDefault().post(result);
            }
        });
    }

    /**
     *获取用户信息
     */
    public void getUserInfo(){
        Api.getInstanceService(Constants.User_URL).getUserInfo().enqueue(new BaseCallback<UserInfoEntity>() {
            @Override
            public void onResponse(Call<UserInfoEntity> call, UserInfoEntity result) {
                EventBus.getDefault().post(result);
                LoadingDialog.get().hideLoading();
            }
        });
    }
}
